import { ask } from '../network/requestBody.js'
import { Decrypt } from '../config/ApiEncrypt.js'

/**
 * 查询用户自己的信息
 */
let getSelUserInfo = async () => {
	return JSON.parse(Decrypt(await ask(['/user/selUserInfo', 'GET', {}])))
}
/**
 *  用户注册接口
 *  /user/login
 */
let postRegister =  (param) => {
	return ask(['/user/register', 'POST', param])
}
/**
 *  用户密码登录接口
 *  /user/login
 */
let postLogin =  (param) => {
	return ask(['/user/login', 'POST', param])
}

/**
 * 校验用户登录
 */
let getVerifyUser =  () => {
	return ask(['/user/verifyUser', 'GET', {}])
}

/**
 * 邮箱登录
 */
let postEmailLogin =  param => {
	return ask(['/user/emailLogin', 'POST', param])
}

/**
 * 获取邮箱验证码
 */
let postSendEmail =  param => {
	return ask(['/user/sendEmail', 'POST', param])
}

/**
 *  用户扫码登录获取二维码接口
 */
let getQRCode =  () => {
	return ask(['/user/getQRcode', 'GET', {}])
}

/**
 * 校验图形验证码
 */
let postVerifyCode =  (param) => {
	return ask(['/user/verifyCode', 'POST', param])
}

/**
 * 更新用户离线中
 */
let getUpdateOffline =  () => {
	return ask(['/user/updateOffline', 'GET', {}])
}

/**
 * 查询贡者
 */
const queryContributors = ()=>ask(['/user/queryContributors', 'GET', {}]);


/**
 * 更新用户信息
 * /user/updateUser
 */
const postUpdateUser = async (param) => {return ask(["/user/updateUser","POST",param])};

export {
	getSelUserInfo,
	postRegister,
	postLogin,
	getQRCode,
	getVerifyUser,
	postUpdateUser,
	postEmailLogin,
	postSendEmail,
	postVerifyCode,
	getUpdateOffline,
	queryContributors
}
